<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>评价管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="../../../static/images/favicon.ico" th:href="@{/images/favicon.ico}">
    <link rel="stylesheet" href="../../../static/back_css/public.css" th:href="@{/back_css/public.css}" media="all" />
    <link rel="stylesheet" href="../../../static/plugin/layui/css/layui.css" th:href="@{/plugin/layui/css/layui.css}" media="all" />
    <link rel="stylesheet" href="../../../static/back_css/user_management.css" th:href="@{/back_css/user_management.css}" media="all">
</head>
<body>
<div class="container">
    <div class="container_content">
        <table class="layui-hide" id="test" lay-filter="test"></table>
    </div>
</div>
<script type="text/javascript" src="../../../static/plugin/layui/layui.js" th:src="@{/plugin/layui/layui.js}"></script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" >删除</a>
</script>
<script type="text/html" id="evaluateTpl">
  {{# if(d.evaluate_RESULT === 1) { }}
    1星
  {{# } else if(d.evaluate_RESULT === 2) { }}
    2星
  {{# } else if(d.evaluate_RESULT === 3) { }}
    3星 
  {{# } else if(d.evaluate_RESULT === 4) { }}
    4星
  {{# } else if(d.evaluate_RESULT === 5) { }}
    5星
  {{# } else { }}
    未知
  {{# } }}
</script>
<script>
    layui.use(['table', 'layer', 'form'], function () {
        var table = layui.table;
        var $ = layui.jquery;
        var form = layui.form;
        table_render('/getUserVotesList');
        function table_render(url) {
            table.render({
                elem: '#test'
                , url:url
                , even: true
                , page: false
                , limit: 20
                , limits: [20, 30]
                , id: 'idTest'
                , cols: [
                    [
                      {type: 'checkbox', fixed: 'left', style: 'display:none'},
                      {field: 'id', width: 70, title: '序号' ,hide: true},
                      {field: 'user_NAME',align: 'center', width: 200, title: '真实姓名'},
                      {field: 'appraisal_USER_ID', align: 'center', width: 300, title: '测评用户ID'},
                      {field: 'evaluate_RESULT', align: 'center', width: 200, title: '评价结果', sort: true, templet: '#evaluateTpl' },
                      {field: 'evaluate_CONTENT', align: 'center', width: 250, title: '评价内容'},
                      {field: 'LAST_UPDATE_TIME', align: 'center', title: '评价时间', width: 200, sort: true },
                      {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 100 }
                    ]
                ] 
            });
        }
        table.on('tool(test)', function (obj) {
        var data = obj.data;
        layer.confirm('<span style="color:#f00;">确认要删除吗？</span>', {
            btn: ['是', '否']
          }, function (index, layero) {
            $.ajax({
              url: '/deleteUserVote',
              async: false,
              type: "POST",
              data: { ID: data.id },
              success: function (data) {
                if (data == "success") {
                  layer.msg("删除成功！")
                  $(".layui-laypage-btn").click();
                } else if (data == "fail") {
                  layer.msg("删除失败···")
                  $(".layui-laypage-btn").click();
                }
              }
            })
          });
      });
    });
</script>
</body>
</html>